/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package Analizador;

/**
 *
 * @author luqui
 */
import javax.swing.table.AbstractTableModel;

public class ModeloDeTabla extends AbstractTableModel {

    private String[] columnNames = {"TOKEN", "LEXEMA", "SwPalRes"};
    private Object[][] data;

    public ModeloDeTabla(String[] tokens, String[] lexemas, String[] reservada) {
        int col = 0;
        
        for (int i = 0; i < tokens.length; i++) {
            if (tokens[i] != null && lexemas[i] != null && reservada[i] != null) {
                col++;
            }
        }
        
        data = new Object[col][3];
        for (int i = 0; i < col; i++) {
            data[i][0] = tokens[i];
            data[i][1] = lexemas[i];
            data[i][2] = reservada[i];
        }
    }

    @Override
    public int getColumnCount() {
        return columnNames.length;
    }

    /**
     *
     * @return
     */
    @Override
    public int getRowCount() {
        return data.length;
    }

    @Override
    public String getColumnName(int col) {
        return columnNames[col];
    }

    /**
     *
     * @param row
     * @param col
     * @return
     */
    @Override
    public Object getValueAt(int row, int col) {
        return data[row][col];
    }
}   // fin de la clase ModeloDeTabla
